home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / keydefs.c < prev    next >
C/C++ Source or Header  |  1988-05-12  |  3KB  |  86 lines

  1.  
  2. /* KeyDefs.C
  3. ** December 7, 1986, David C. Oshel
  4. **
  5. ** Displays a popout window with the ten Fn keys drawn down the middle
  6. ** The function names are listed in 21 character fields to left and right
  7. ** Sample arrays of menu strings are shown below, all 10 must be defined
  8. ** even if the string is null.
  9. ** Waits for response from the user, if ESC is typed, returns F1
  10. */
  11.  
  12. #include "ciao.h"
  13. #include "keys.h"
  14. #define keycatcher() flush_keys()
  15.  
  16. /* strings may be up to 21 chars, preferably no more than 18
  17. */
  18.                    /* ....v....1....v....2. */
  19.  
  20. /* note: example arrays show how to duplicate strings in the menus! 
  21. ** "phi" is a glyph meaning "undefined function" in one application
  22. **
  23.  
  24. static char nyi[] = "φ",
  25.             sco[] = "Screen Colors",
  26.             klk[] = "Key Click";
  27.  
  28. char *MainMenu[] = { "Quit Program",             "Help", 
  29.                      "Chart of Accounts",        "General Journal", 
  30.                      "User Information",         "Trial Balance",
  31.                       sco,                       "Close the Books",
  32.                       klk,                       "Financial Reports"
  33.                    };
  34.  
  35. char *JnlMenu[] =  { "Quit Program",             "List Fn Keys",
  36.                      "List Chart of Accts",      "Review Journal Docs",
  37.                       nyi,                        nyi,
  38.                       sco,                        nyi,
  39.                       klk,                        nyi
  40.                    };
  41. **
  42. */
  43.  
  44. int KeyDefs( name, menutitle, msg ) 
  45. char **name, *menutitle, *msg;
  46. {
  47.      char far *p; union REGS x;  
  48.      static int i,n;
  49.      char *blks,*dots;
  50.  
  51.      blks = "                     ",
  52.      dots = ".....................";
  53.  
  54.      p = savescreen( &x );  /* save caller's original screen */
  55.      windowbox ( 13, 3, 53 + 13, 20 + 3 );
  56.  
  57.      gotoxy( ((53 - strlen( menutitle )) / 2), 1 ); 
  58.      wprintf("%s\n\n", menutitle );
  59.  
  60.      /* draw key boxes */ 
  61.      for (n = 1, i = 0; i < 5; n += 2, i++)
  62.      {
  63.         wink(' '); wputs(blks); wputs("╔═══╗╔═══╗\n"); 
  64.         wink(' '); wputs(dots); wprintf("║F%-2d║║F%-2d║", n, n + 1); 
  65.                    wputs(dots); wink('\n');
  66.         wink(' '); wputs(blks); wputs("╚═══╝╚═══╝\n");
  67.      }
  68.  
  69.      /* fill in key names */
  70.      for ( n = 4, i = 0; i < 5; n += 3, i++)
  71.      {
  72.           gotoxy( 1, n );                   wputs( *name++ ); /* left  */
  73.           gotoxy((53 - strlen(*name)), n ); wputs( *name++ ); /* right */
  74.      }
  75.  
  76.      gotoxy( ((53 - strlen( msg )) / 2), 19 ); wputs( msg );
  77.      defcursor();
  78.      keycatcher();
  79.      n = getkey();
  80.      if (n == ESC) n = F1;
  81.      restorescreen( p, &x );
  82.      return (n);
  83. }
  84.  
  85.  
  86.